import { request } from "@/utils/request";
import type { User, CodeType, UserInfo, PatientList, EmptyObject,Patient } from '@/types/user'

// 密码登陆
export const loginPsAPI = ( mobile: string,password:string) => {
  return request.post<User>('/login/password',{mobile,password})
}
// 验证码接收
export const codeLoginAPI = (mobile: string, type:CodeType) => {
  return request.get<{code:string}>('/code', {
    params: {
      mobile,
      type
}})
}
// 验证码登录
export const codeFineLoginAPI = (mobile:string,code:string) => {
  return request.post<User>('/login',{mobile,code})
}
// 获取个人信息
export const getUserInfoApi = () => request.get<UserInfo>('/patient/myUser')

// 问诊-查询患者列表信息
export const queryPatientListAPI = () => {
  return request.get<PatientList>('/patient/mylist')
}

// 问诊-添加患者信息
export const addPatientAPI = (data:EmptyObject) => {
  return request.post<EmptyObject>('/patient/add',data)
}

// 问诊-查询患者详情
export const queryPatientDetailAPI = (id:string) => {
  return request.get<Patient>(`/patient/info/${id}`)
}

// 问诊-编辑患者信息
export const editPatientDetailAPI = (patient:Patient) => {
  return request.put('/patient/update',patient)
}
// 问诊-删除患者信息
export const delPatientAPI = (id:string) => {
  return request.delete(`/patient/del/${id}`)
}

// 查询患者详情
export const getPatientDetail = (id: string) => request.get<Patient>(`/patient/info/${id}`)